home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: advtr@ix.netcom.com(Advance Trading)
- Newsgroups: comp.lang.c
- Subject: Finding a prime number
- Date: 25 Jan 1996 15:21:32 GMT
- Organization: Netcom
- Message-ID: <4e875s$nqk@reader2.ix.netcom.com>
- NNTP-Posting-Host: ix-tf4-06.ix.netcom.com
- X-NETCOM-Date: Thu Jan 25 7:21:32 AM PST 1996
-
- I need to write a function that will find wether or not a number is
- prime. I can come close but I get numbers that are not prime with the
- prime numbers.
- Here is the function I wrote. Any help would be great. Thanks Ken(A
- begining C programmer)
-
- int primenumber(int operand)
- {/*Start primenumber*/
- int two = 0,three = 0,four = 0,five = 0,six = 0,seven = 0;
- int eight = 0,nine = 0;
-
-
- two =(operand%2);
- three =(operand%3);
- four = (operand%4);
- five = (operand%5);
- six = (operand%6);
- seven = (operand%7);
- eight = (operand%8);
- nine = (operand%9);
-
- if (two ==0||three==0||four==0||five==0||six==0
- ||seven==0||eight==0||nine==0)
- return 0;
- else
- return 1;
- }/*End primenumber*/
-